<?php
namespace Admin\Controller;
use Think\Controller;
class EditActivityController extends Controller {
    public function index() {
        $this->display('./Public/admin/edit_activity.html');
    }

    public function save() {
        if (!empty($_POST))
        {
//            if ( get_magic_quotes_gpc() ) {
//                $_POST['content'] = htmlspecialchars($_POST['content']);
//            } else {
//                $_POST['content'] = htmlspecialchars(addslashes($_POST['content']));
//            }
//            $_POST['type'] = intval($_POST['type']);
//            if (isset($_POST['pid'])) {
//                $_POST['pid'] = intval($_POST['pid']);
//            }
            $map['title'] = $_POST['title'];
            $map['summary'] = $_POST['summary'];
            $map['pid'] = intval($_POST['pid']);
            $map['time'] = $_POST['time'];
            $map['location'] = $_POST['location'];
            //$map['join_number'] = 0;
            if (get_magic_quotes_gpc()) {
                $map['content'] = htmlspecialchars($_POST['content']);
            } else {
                $map['content'] = htmlspecialchars(addslashes($_POST['content']));
            }
            $activity = D('Activity');
            if ($activity->create($map)) {
                if ($activity->add()) {
                    $this->success('新增成功', U('Admin/Index/activity'), 3);
                } else $this->error('新增失败');
            } else $this->error('create失败');
        }
    }
}